package com.cloudpivot.receivales.contract.repository.erpcontract;

import com.cloudpivot.receivales.contract.entity.erpcontract.LastContractId;
import com.cloudpivot.receivales.contract.entity.erpcontract.MiddleEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * u8中间表 接口
 */
@Repository
@Transactional(rollbackFor = Exception.class)
public interface U8MiddleRepository extends JpaRepository<MiddleEntity,String> {

    @Modifying
    @Query(nativeQuery = true,value = "insert into U8MiddleData..Tbl_CRM_Result (cAccId,cVouchType,U8Id,AutoId,CRMId,dCreateDate,cCode) values (:#{#entity.CAccId},'合同档案',:#{#entity.u8Id},null,:#{#entity.CRMId},:#{#entity.DCreateDate},:#{#entity.u8Id})")
    void addU8ResultToMiddle(MiddleEntity entity);
}
